-
Notifications
You must be signed in to change notification settings - Fork 55
Move Metering cluster formatting out of cluster handler and into sensor entity
#565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #565 +/- ##
==========================================
- Coverage 96.95% 96.91% -0.04%
==========================================
Files 63 63
Lines 10534 10544 +10
==========================================
+ Hits 10213 10219 +6
- Misses 321 325 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| "version": 1, | ||
| "ieee": "ab:cd:ef:12:b5:0f:0b:2f", | ||
| "nwk": "0x5C8B", | ||
| "manufacturer": "_TZE200_a7sghmms", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, interesting that it affected this Tuya valve with a v2 quirk. We have a local Metering cluster for that and it's one of the few times we actually do not use kW(h) as the unit for it, but instead water/liters:
https://github.com/zigpy/zha-device-handlers/blob/928268cca5d22a048e72d45ae1c24a1b6dd92a9c/zhaquirks/tuya/builder/__init__.py#L128-L148
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked through the endpoint/ch initialization code and we skip important parts if "skip configuration" is enabled, both binding and attribute reporting in ch.async_configure but also the ch specific init code in ch.async_initialize, which later runs the ch specific init.
And sure enough, the quirk enables it: zhaquirks/tuya/tuya_valve.py#L115
So, that at least solves the why behind the cluster handler specific initialization code not running.
Moving the Metering cluster formatting out of the cluster handler might actually break the entity displaying the delivered summation, now that the code is executed.
But agreed this is something we should do.
TheJulianJES
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be good, though it might break that one Tuya device until the quirk is updated
When working on #557 I ran into a bug: diagnostics could not be regenerated for a specific device. For some reason, the cluster handler-specific initialization code did not run.
The cluster handler computed something that realistically should be handled by the entity so I ported the code over into there. This has the benefit of now allowing the summation formatting to change at runtime.